package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.TipInfo;

/**
 * 
 * @author 
 *
 */
@DAO
public interface TipInfoDAO{
	
	@SQL("SELECT id,toAddress,title,descs,imgUrl,link,address,deleteFlag,createUser,date_format(createAT,'%Y-%m-%d %H:%i:%s') as createAT,updateUser,date_format(updateAT,'%Y-%m-%d %H:%i:%s') as updateAT FROM TipInfo WHERE deleteFlag=1  AND title like '%##(:1)%' ORDER BY updateAT DESC LIMIT :2,:3 ")
    List<TipInfo> query(String title,int start,int length);
	
	@SQL("SELECT count(id) FROM TipInfo WHERE deleteFlag=1  AND title like '%##(:1)%' ")
	int querysize(String title);
    
    @SQL("select * from TipInfo where id=:1")
    TipInfo queryById(String id);
    
    @SQL("INSERT INTO TipInfo (id,toAddress,title,descs,imgUrl,link,phone,address,deleteFlag,createUser,createAT,updateUser,updateAT) VALUES (:t.id,:t.toAddress,:t.title,:t.descs,:t.imgUrl,:t.link,:t.phone,:t.address,:t.deleteFlag,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") TipInfo tipInfo);
	
	@SQL("UPDATE TipInfo SET toAddress=:t.toAddress,title=:t.title,descs=:t.descs,imgUrl=:t.imgUrl,link=:t.link,phone=:t.phone,address=:t.address,updateUser=:t.updateUser,updateAT=now() WHERE id=:t.id")
    void update(@SQLParam("t") TipInfo tipInfo);
    
    @SQL("UPDATE TipInfo SET deleteFlag=0 WHERE id=:1")
    void deleteById(String id);
}